package Demo24;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CountAB extends JFrame{
    private JTextField a = new JTextField(7);
    private JTextField b = new JTextField(7);
    private JLabel c = new JLabel();
    private JButton button = new JButton("=");
    public CountAB(){
        baiinit();
    }

    private void baiinit() {
    }

    public void showView(){
        setVisible(true);
    }
    public void init(){
        a.setSize(70,50);
        setSize(400,100);
        JPanel pane = new JPanel(new FlowLayout());
        pane.add(a);
        pane.add(new JLabel("+"));
        pane.add(b);
        pane.add(button);
        pane.add(c);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                c.setText(Integer.parseInt(a.getText()) + Integer.parseInt(b.getText())+"");
            }
        });
        setContentPane(pane);
    }
    public static void main(String[] args) {
        new CountAB().showView();
    }
}